<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  
    
      
    

    
  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic|Monda:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Github,Hexo," />








  <link rel="shortcut icon" type="image/x-icon" href="/images/favicon.png?v=5.0.1" />






<meta name="description" content="什么是Hexo?Hexo是一个快速、简介且高效的博客框架。Hexo使用Markdown（或其他渲染引擎）解析文章，在几秒内，即可利用靓丽的主题生成静态网页
安装前提安装Hexo之前，需要安装下列程序

Node.js
Git

安装Hexo
$ npm install -g hexo-cli

快速体验Hexo
初始化Hexo文件夹

$ hexo init &amp;lt;folder&amp;gt; &amp;amp">
<meta property="og:type" content="article">
<meta property="og:title" content="使用Hexo与Github Pages搭建个人博客">
<meta property="og:url" content="ooho.me/2016/07/27/使用Hexo与Github-Pages搭建个人博客/index.html">
<meta property="og:site_name" content="Ooho's blog">
<meta property="og:description" content="什么是Hexo?Hexo是一个快速、简介且高效的博客框架。Hexo使用Markdown（或其他渲染引擎）解析文章，在几秒内，即可利用靓丽的主题生成静态网页
安装前提安装Hexo之前，需要安装下列程序

Node.js
Git

安装Hexo
$ npm install -g hexo-cli

快速体验Hexo
初始化Hexo文件夹

$ hexo init &amp;lt;folder&amp;gt; &amp;amp">
<meta property="og:updated_time" content="2016-07-29T08:35:56.708Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="使用Hexo与Github Pages搭建个人博客">
<meta name="twitter:description" content="什么是Hexo?Hexo是一个快速、简介且高效的博客框架。Hexo使用Markdown（或其他渲染引擎）解析文章，在几秒内，即可利用靓丽的主题生成静态网页
安装前提安装Hexo之前，需要安装下列程序

Node.js
Git

安装Hexo
$ npm install -g hexo-cli

快速体验Hexo
初始化Hexo文件夹

$ hexo init &amp;lt;folder&amp;gt; &amp;amp">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"right","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="ooho.me/2016/07/27/使用Hexo与Github-Pages搭建个人博客/"/>

  <title> 使用Hexo与Github Pages搭建个人博客 | Ooho's blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-right page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Ooho's blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">Intergrated delay cancer</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-terminal"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-folder-open-o"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-clone"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-square-o"></i> <br />
            
            标签
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                使用Hexo与Github Pages搭建个人博客
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-07-27T11:15:28+08:00" content="2016-07-27">
              2016-07-27
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Hexo/" itemprop="url" rel="index">
                    <span itemprop="name">Hexo</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="什么是Hexo"><a href="#什么是Hexo" class="headerlink" title="什么是Hexo?"></a>什么是Hexo?</h2><p>Hexo是一个快速、简介且高效的博客框架。Hexo使用Markdown（或其他渲染引擎）解析文章，<br>在几秒内，即可利用靓丽的主题生成静态网页</p>
<h2 id="安装前提"><a href="#安装前提" class="headerlink" title="安装前提"></a>安装前提</h2><p>安装Hexo之前，需要安装下列程序</p>
<ul>
<li>Node.js</li>
<li>Git</li>
</ul>
<h2 id="安装Hexo"><a href="#安装Hexo" class="headerlink" title="安装Hexo"></a>安装Hexo</h2><blockquote>
<p>$ npm install -g hexo-cli</p>
</blockquote>
<h2 id="快速体验Hexo"><a href="#快速体验Hexo" class="headerlink" title="快速体验Hexo"></a>快速体验Hexo</h2><ul>
<li><p>初始化Hexo文件夹</p>
<blockquote>
<p>$ hexo init &lt;folder&gt; &amp;&amp; cd &lt;folder&gt;</p>
</blockquote>
</li>
<li><p>生成静态页面并预览</p>
<blockquote>
<p>$ hexo g &amp;&amp; hexo s</p>
</blockquote>
</li>
<li><p>在浏览器中输入<code>localhost:4000</code>，一个Hexo站点就展示在你面前了</p>
</li>
</ul>
<a id="more"></a> 
<h2 id="目录结构"><a href="#目录结构" class="headerlink" title="目录结构"></a>目录结构</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">.</div><div class="line">├── _config.yml</div><div class="line">├── package.json</div><div class="line">├── scaffolds</div><div class="line">├── scripts</div><div class="line">├── source</div><div class="line">|   ├── _drafts</div><div class="line">|   └── _posts</div><div class="line">└── themes</div></pre></td></tr></table></figure>
<ul>
<li><p>_config.yml : 配置文件，主要配置自己的站点信息，配置文件中注释非常详细，<br>如果不懂的话，可以去Hexo官网文档中查看（Hexo是台湾人做的，对中文友好）</p>
</li>
<li><p>scaffolds : 脚手架，大概是一些插件什么的，先不用管</p>
</li>
<li><p>source/_drafts : 草稿文件目录</p>
</li>
<li><p>source/_posts : 发表的博文目录</p>
</li>
<li><p>themes : 下载的主题目录。更多的主题，只需要git clone到themes中，然后修改<br>config.yml中的theme字段就可以了，十分方便</p>
</li>
</ul>
<p>其它目录先不用管</p>
<h2 id="常用指令"><a href="#常用指令" class="headerlink" title="常用指令"></a>常用指令</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">$ hexo new [layout] &lt;title&gt;   #建立新文章，默认在_posts下，layout=&quot;draft&quot;时发布的是草稿</div><div class="line">$ hexo public &lt;filename&gt;      #将_drafts下的文件放到_posts下，发布草稿</div><div class="line">$ hexo generate               #生成静态网页</div><div class="line">$ hexo server                 #启动预览服务器，开启-d选项预览草稿</div><div class="line">$ hexo deploy                 #发布到远程服务器，开启--generate选项可以在deploy前自动generate</div></pre></td></tr></table></figure>
<p>简化版<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">$ hexo n  # == hexo new</div><div class="line">$ hexo p  # == hexo publish</div><div class="line">$ hexo g  # == hexo generate</div><div class="line">$ hexo s  # == hexo server</div><div class="line">$ hexo d  # == hexo deploy</div></pre></td></tr></table></figure></p>
<h2 id="第一个博客"><a href="#第一个博客" class="headerlink" title="第一个博客"></a>第一个博客</h2><p>文章头部信息，以<code>---</code>结尾<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">title: 我的第一篇博客</div><div class="line">layout: post</div><div class="line">date: 2016-4-13</div><div class="line">comments: true</div><div class="line">categories: Blog</div><div class="line">tags: [blog]</div><div class="line">keywords: Hexo, blog</div><div class="line">description: Hexo上第一篇博客</div><div class="line">---</div></pre></td></tr></table></figure></p>
<p>接下来使用Markdown编辑文章就可以了</p>
<h2 id="部署到GitHub-Pages上"><a href="#部署到GitHub-Pages上" class="headerlink" title="部署到GitHub Pages上"></a>部署到GitHub Pages上</h2><ul>
<li><p>更改<code>_config.yml</code>中的配置</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">deploy:</div><div class="line">    type: git</div><div class="line">    repo: &lt;repository url&gt;</div><div class="line">    branch: [branch]</div><div class="line">    message: [message]</div></pre></td></tr></table></figure>
</li>
<li><p>运行<code>$ npm install hexo-deployer-git --save</code>，安装git的deployer</p>
</li>
<li><p>运行<code>$ hexo g -d</code></p>
</li>
<li><p>部署完成，用浏览器打开<code>http://username.github.io</code></p>
</li>
</ul>
<h2 id="GitHub-Pages绑定独立域名"><a href="#GitHub-Pages绑定独立域名" class="headerlink" title="GitHub Pages绑定独立域名"></a>GitHub Pages绑定独立域名</h2><ul>
<li><p>在source中添加<code>CNAME</code>文件</p>
</li>
<li><p>在<code>CNAME</code>中写入独立域名，比如我的域名</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">ooho.me</div></pre></td></tr></table></figure>
</li>
<li><p>在<code>dnspod</code>(或其他DNS服务商)中添加记录，选择别名记录<code>CNAME</code>，主机值选<code>@</code><br>(或别名记录<code>CNAME</code>，主机值选<code>wwww</code>)，在记录值中写上自己的github pages域名，<br>比如<code>hughoo.github.io</code></p>
</li>
<li><p>在<code>GoDaddy</code>上设置自己的独立域名的DNS服务器IP(比如dnspod服务器的IP)</p>
</li>
<li><p>运行</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$ hexo g -d</div></pre></td></tr></table></figure>
</li>
</ul>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Github/" rel="tag">#Github</a>
          
            <a href="/tags/Hexo/" rel="tag">#Hexo</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/07/27/没有标题只有图片的文章/" rel="prev" title="Images">
                Images <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.jpg"
               alt="Ooho" />
          <p class="site-author-name" itemprop="name">Ooho</p>
          <p class="site-description motion-element" itemprop="description">Intergrated delay cancer</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">3</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">4</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#什么是Hexo"><span class="nav-number">1.</span> <span class="nav-text">什么是Hexo?</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#安装前提"><span class="nav-number">2.</span> <span class="nav-text">安装前提</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#安装Hexo"><span class="nav-number">3.</span> <span class="nav-text">安装Hexo</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#快速体验Hexo"><span class="nav-number">4.</span> <span class="nav-text">快速体验Hexo</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#目录结构"><span class="nav-number">5.</span> <span class="nav-text">目录结构</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#常用指令"><span class="nav-number">6.</span> <span class="nav-text">常用指令</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#第一个博客"><span class="nav-number">7.</span> <span class="nav-text">第一个博客</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#部署到GitHub-Pages上"><span class="nav-number">8.</span> <span class="nav-text">部署到GitHub Pages上</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#GitHub-Pages绑定独立域名"><span class="nav-number">9.</span> <span class="nav-text">GitHub Pages绑定独立域名</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2016</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Ooho</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  



  




  
  

  

  

  

</body>
</html>
